{% extends "forum/frame.html" %}
{% load string %}
{% load i18n %} 
{% load ytcomment %}
{% load ytutil %}

{% block description %}
  <meta name="description" content="{{ board.title|escape }}, {{post.title|escape}}">
{% endblock %}

{% block content %}

  <div id="forum_nav">
  <a class="forum_link" href="{% url ytcommunity.forum.view.board.list %}">{% trans 'Homepage' %}</a>
  
  {% for board in board.get_board_path %}
  - <a class="forum_link" href="{% url ytcommunity.forum.view.board.display name=board.get_board_key %}">{{ board.title|escape }}</a>
  {% endfor %}
  </div>

  <table id="forum" cellspacing="1">
    <thead>
      <tr>
        <td class="forum_title" style="width: 20%;">{% trans 'Author' %}</td>
        <td class="forum_title" style="width: 80%; border-right: 1px solid white;">{{ post.title|escape }}</a></td>
      </tr>
    </thead>
    <tbody>
    
    <tr>
    <td class="forum_body">
    {{ post.author.ga }}<br>{{ post.date|timedelta|date:"Y-m-d H:i" }}
    </td>
    <td class="forum_body">
        <div>
        {{ post.content|removetags:"script"|safe }}
        </div>
    
      <div class="ForumOperation">
      {% if post.auth.edit %}
      <div class="ForumButton">
        <a class="ForumOperation" href="{% url ytcommunity.forum.view.post.edit post.key.id %}">{% trans 'Edit' %}</a>
      </div>
      {% endif %}
    
      {% if post.auth.delete %}
    <div class="ForumButton" 
      onclick="post_and_replace('{% url ytcommunity.forum.view.post.delete post.key.id %}',
          '{% url ytcommunity.forum.view.board.display name=post.ref.get_board_key %}');">
      <span>{% trans 'Delete' %}</span>
    </div>    
      {% endif %}

      {% if user.admin %}
      {% if post.hot %}
    <div class="ForumButton" 
      onclick="post_and_reload('{% url ytcommunity.forum.view.post.unstick post.key.id %}')">
      <span>{% trans 'Unstick' %}</span>
    </div>
      {% else %}
    <div class="ForumButton" 
      onclick="post_and_reload('{% url ytcommunity.forum.view.post.stick post.key.id %}')">
      <span>{% trans 'Stick' %}</span>
    </div>
      {% endif %}
      {% endif %}
    
      </div>
      
        {% for plugin in plugins_post_bottom %}
        {% include plugin.config.view_path %}
        {% endfor %}      
      
    </td>
    </tr>    
    
    {% get_comment_list for post as comments paginator page comment_num_per_page %}
    {% for comment in comments %}
    <tr>
    <td class="forum_body">
    {{ comment.author.ga }}<br>{{ comment.date|timedelta|date:"Y-m-d H:i" }}
    </td>
    <td class="forum_body">
    {{ comment.content|removetags:"script"|safe }}
    
    <div class="CommentOperation">
    {% if comment.auth.delete %}
    <div class="ForumButton" onclick="post_and_reload('{% url ytcommunity.forum.view.comment.delete comment.key.id %}')">
      <span>{% trans 'Delete' %}</span>
    </div>    
    {% endif %}
    </div>
    
    </td>
    </tr>
    {% endfor %}
  
    </tbody>
    
  </table>  

{% if page_info.prev or page_info.next %}
<div id="BlogPagination" class="pagination">
{% if page_info.prev %}
<a class="prev" href="{% url ytcommunity.forum.view.post.display %}?page={{page_info.prev_page}}">{% trans 'Previous Page' %}</a>
{% endif %}
{% if page_info.next %}
<a class="next" href="{% url ytcommunity.forum.view.post.display %}?page={{page_info.next_page}}">{% trans 'Next Page' %}</a>
{% endif %}
</div>
{% endif %}
    
  <div class="CommentAdd">
  {% if auth_comment.add %}
  <form action="{% url ytcommunity.forum.view.comment.add post.key.id%}" method="post">
    <div class="fieldWrapper">
        {{ form.content.errors }}
        <label for="id_content">{% trans "Reply" %}:</label><br>
        {{ form.content }}
    </div>    
    
    <div>
    <input type="submit" class="button" value="{% trans 'Add' %}">
    </div>
  </form>

  {% endif %}
  </div>
  
{% endblock %}
